/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tp3_1_server;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.*;

/**
 *
 * @author aj48450
 */
public class Server
{
    private ServerSocket sSocket;
    private BufferedReader in;
    private PrintWriter out;



    public Server (int port )
    {
        try
        {
            sSocket = new ServerSocket(port);

            Socket ecoute = sSocket.accept();

            in = new BufferedReader (new InputStreamReader(ecoute.getInputStream()));

            out = new PrintWriter (ecoute.getOutputStream(), true);

            GetMessage();

        }
        catch ( Exception e )
        {

        }
    }

    private void GetMessage ( )
    {
        String line = "";

        try
        {
            while ( ( line = in.readLine() ) != null )
            {
                System.out.println(line + "\n");
            }
        }
        catch ( Exception e )
        {

        }
    }
}
